import React, { PureComponent } from 'react';
import BodyStruct from './BodyStruct';
import Body from './Body';
import MBody from './MBody'

export default class StructCanvas extends PureComponent {
  state = {

  }
  componentDidMount() {

  }
  componentWillUnmount() {

  }
  render() {
    const { form, props, name, rules, operation } = this.props;
    let StructCanvas = '';
    if (name === 'bodyStruct') {
      StructCanvas = <BodyStruct form={form} name={name} props={props} rules={rules} onChange={this.props.onChange} operation={operation} />
    } else if (name === 'body') {
      StructCanvas = <Body form={form} name={name} props={props} rules={rules} onChange={this.props.onChange} operation={operation} />
    } else {
      if (props.enableAutoOrder === 'single-item-rank:topNum;' || props.enableAutoOrder === 'single-item-inventory:topNum;') {
        StructCanvas = <Body form={form} name={name} props={props} rules={rules} onChange={this.props.onChange} operation={operation} />
      } else {
        StructCanvas = <MBody {...props}/>
      }
    }
    return (
      <div>
        {StructCanvas}
      </div>
    );
  }
}
